// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()
// 云函数入口函数
exports.main = (event, context) => {
  //插入数据
  return new Promise((resolve, reject) => {
    resolve(db.collection('room').add ({
      data: {
        room_name: event.room_name,  //前端提交过来的数据
        room_password: event.room_password,
        users: event.users,
        ready_num: event.ready_num,
        viewer: event.viewer,
        tasks: event.tasks,
        mode:event.mode,
        room_state: event.room_state,
        is_start: event.is_start,
        create_time:event.create_time
      }
    }))
  }) 
}
